import 'package:base_widgets/export.dart';
import 'package:base_widgets/widget/paging_data.dart';
import 'package:flutter/widgets.dart';

import '../../network/app_api_service.dart';
import '../bean/HomeArticleBean.dart';

class HomeChangeNotifier extends PagingListChangeNotifier<HomeArticleData> {
  HomeChangeNotifier() : super(firstPageIndex: 0);

  @override
  Future<PagingData<HomeArticleData>> loadPagingData(BuildContext context,
      {int pageIndex = 0, bool reset = false}) async {
    HomeArticleBeanList result = await AppApiService.requestHomeArticle(context, pageIndex);
    pagingData
      ..hasNext = (result.data?.pageCount ?? 0) > (result.data?.curPage ?? 0)
      ..dataList.addAll(result.data?.datas ?? []);
    return pagingData;
  }
}
